package day1026_2;

class NameWrongException extends  Exception{}

public class E2 {
    //main： 调用test ,  用try-catch-finally捕获"test();"异常
    public static void main(String[] args) {
        try {
            new E2().test();
        } catch (NameWrongException e) {
            System.out.println(e.getMessage());
        } finally {
            System.out.println("异常处理最后执行的内容");
        }
    }
    public void test()throws NameWrongException{
        String name="%刘琪_";
        if(name.contains("%")){//必须添加代码处理此异常
            throw  new NameWrongException();
        }
    }
}






